package com.ruoyi.push;

import com.ruoyi.framework.web.websocket.WebSocketUtils;
import com.ruoyi.framework.web.websocket.vo.WsMessage;
import org.springframework.stereotype.Component;

/**
 * 通过WS推送消息
 */
@Component("wsPush")
public class WsPushChannel implements PushChannel{
    @Override
    public void pushMessage(WsMessage msg) {
        WebSocketUtils.sendToAll(msg.toString());
    }

    @Override
    public void pushMessage(PushUser user, WsMessage msg) {
        WebSocketUtils.sendToUser(user.getUserId(), msg.toString());
    }
}
